package com.ruoyi.supplier.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.supplier.mapper.TOrdersMapper;
import com.ruoyi.supplier.domain.TOrders;
import com.ruoyi.supplier.service.ITOrdersService;

import javax.annotation.Resource;

/**
 * 订单信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-05-22
 */
@Service
public class TOrdersServiceImpl implements ITOrdersService 
{
    @Resource
    private TOrdersMapper tOrdersMapper;

    /**
     * 查询订单信息
     * 
     * @param orderId 订单信息主键
     * @return 订单信息
     */
    @Override
    public TOrders selectTOrdersByOrderId(String orderId)
    {
        return tOrdersMapper.selectTOrdersByOrderId(orderId);
    }

    /**
     * 查询订单信息列表
     * 
     * @param tOrders 订单信息
     * @return 订单信息
     */
    @Override
    public List<TOrders> selectTOrdersList(TOrders tOrders)
    {
        return tOrdersMapper.selectTOrdersList(tOrders);
    }

    /**
     * 新增订单信息
     * 
     * @param tOrders 订单信息
     * @return 结果
     */
    @Override
    public int insertTOrders(TOrders tOrders)
    {
        tOrders.setCreateTime(DateUtils.getNowDate());
        return tOrdersMapper.insertTOrders(tOrders);
    }

    /**
     * 修改订单信息
     * 
     * @param tOrders 订单信息
     * @return 结果
     */
    @Override
    public int updateTOrders(TOrders tOrders)
    {
        tOrders.setUpdateTime(DateUtils.getNowDate());
        return tOrdersMapper.updateTOrders(tOrders);
    }

    /**
     * 批量删除订单信息
     * 
     * @param orderIds 需要删除的订单信息主键
     * @return 结果
     */
    @Override
    public int deleteTOrdersByOrderIds(String[] orderIds)
    {
        int res = 1;
        for (String s : orderIds) {
            TOrders tOrders = new TOrders();
            tOrders.setOrderId(s);
            tOrders.setStatus("0");
            res &= tOrdersMapper.updateTOrders(tOrders);
        }

        return res;
    }

    /**
     * 删除订单信息信息
     * 
     * @param orderId 订单信息主键
     * @return 结果
     */
    @Override
    public int deleteTOrdersByOrderId(String orderId)
    {
        TOrders tOrders = new TOrders();
        tOrders.setStatus("0");
        tOrders.setOrderId(orderId);
        return tOrdersMapper.updateTOrders(tOrders);
    }
}
